import { requestClient } from '#/api/request';

// 1688的商品详情
export async function getProductDetailById(data: any) {
  return requestClient.get<any>('yx1688/getProductDetailById', {
    params: data,
  });
}

// 1688发布到抖店
export async function get1688ToDouyinProduct(data: any) {
  return requestClient.post<any>('business/addDYGoods', data);
}

// 上架商品
export async function setGoodsOnLine(data: any) {
  return requestClient.post<any>('business/setGoodsOnLine', { tbId: data });
}

//检查抖店商品状态
export async function checkDYGoodsStatusList(data: any) {
  return requestClient.get<any>('business/checkDYGoodsStatusList', {params: data, });
}


// 获取详情
export async function get1688ToDouyinProductDetail(data: any) {
  return requestClient.post<any>('business/getDYGoodsDetail', data);
}

// 1688发布到抖店 business/addDYGoodsList
export async function get1688ToDouyinProductList(data: any) {
  return requestClient.post<any>('business/addDYGoodsList', data);
}

// 获取铺货记录
export async function getDYGoodsListFu(data: any) {
  return requestClient.get<any>('business/getDYGoodsList', {
    params: data,
  });
}
export async function delDYGoodsInfo(data: any) {
  return requestClient.post<any>('business/delDYGoodsInfo', data);
}

// 获取订单列表
export async function getOrderList(data: any) {
  return requestClient.get<any>('order/getOrderList', {
    params: data,
  });
}

// 获取店铺每天利润列表
export async function getShopProfitEveryDayList(data: any) {
  return requestClient.get<any>('merchantData/getShopProfitEveryDayList', {
    params: data,
  });
}

// 获取商户整体数据
export async function getMerchantData(data?: any) {
  return requestClient.get<any>('merchantData/getMerchantData', {
    params: data,
  });
}

// 获取单店整体利润
export async function getShopProfitTotalList(data: any) {
  return requestClient.get<any>('merchantData/getShopProfitTotalList', {
    params: data,
  });
}

// 获取单店最近多少天的数据(折线图)
export async function getShopLastDaysData(data?: any) {
  return requestClient.get<any>('merchantData/getShopLastDaysData', {
    params: data,
  });
}

// 订单状态同步
export async function asyncOrderStatus(data?: any) {
  return requestClient.get<any>('order/asyncOrderStatus', {
    params: data,
  });
}

//清空采购订单
export async function delAliOrder(data?: any) {
  return requestClient.get<any>('order/delAliOrder', {
    params: data,
  });
}

export async function getOrderDetail(data: any) {
  return requestClient.post<any>('order/getOrderDetail', { tbId: data });
}

export async function purchaseGoods(data: any) {
  return requestClient.post<any>('order/purchaseGoods', { tbId: data });
}

export async function payOrder(data: any) {
  return requestClient.post<any>('order/payOrder', { tbId: data });
}

/**
 * 批量下单支付
 * @param data {tbIds: string, types: int}
 * @returns ‘’
 */
export async function purchaseGoodsAndPayApi(data: any) {
  return requestClient.post<any>('order/purchaseGoodsAndPay', data);
}

export async function createRefund(data: any) {
  return requestClient.post<any>('order/createRefund', { tbId: data });
}

export async function cancelRefund(data: any) {
  return requestClient.post<any>('order/cancelRefund', { tbId: data });
}

export async function getLogisticsTraceInfoList(data: any) {
  return requestClient.post<any>('order/getLogisticsTraceInfoList', {
    tbId: data,
  });
}

export async function getRefundReasonList(data: any) {
  return requestClient.post<any>('order/getRefundReasonList', { tbId: data });
}

export async function queryBatchRefundByRefundId(data: any) {
  return requestClient.post<any>('order/queryBatchRefundByRefundId', {
    tbId: data,
  });
}
/** 同步抖店订单列表 */
export async function getDouyinOrderList(data?: any) {
  return requestClient.get<any>('order/getDyOrderList', {
    params: data,
  });
}
/** 设置默认应用 */
export async function setDefaultApp(data: any) {
  return requestClient.get<any>('merchant/changeShopUseing', {
    params: data,
  });
}

/**
 * 关联1688货源
 */
export async function bind1688Source(data: any) {
  return requestClient.post<any>('bindGoods/bindGoodsByProductId', data);
}
/**
 * 修改货源采购数量
 */
export async function update1688Source(data: any) {
  return requestClient.post<any>('order/updateOrder', data);
}

/** 关联1688货源 */
export async function bind1688SourceApi(data: any) {
  return requestClient.post<any>('bindGoods/selectBindGoodsFrom1688', data);
}

/** 获取已经关联的货源 */
export async function getBind1688SourceApi(data: any) {
  return requestClient.get<any>('bindGoods/getBindGoodsFrom1688', {
    params: data,
  });
}

/** 获取1688sku详情列表 */
export async function get1688SkuListApi(data: any) {
  return requestClient.post<any>('bindGoods/getSkuList1688', data);
}

/** 删除已关联的货源 */
export async function deleteBind1688SourceApi(data: any) {
  return requestClient.post<any>('bindGoods/delBindGoods', data);
}

// /** 关联1688货源 */
// export async function bind1688SourceListApi(data: any) {
//   return requestClient.post<any>('bindGoods/selectBindGoodsFrom1688', data);
// }

/** 关联sku货源 */
export async function bind1688SkuSourceApi(data: any) {
  return requestClient.post<any>('bindGoods/saveBindGoods', data);
}

/** 获取地址列表 */
export async function getAddressListApi(data: any) {
  return requestClient.get<any>('afterSale/getAddressList', {
    params: data,
  });
}

/** 新增修改地址库地址 */
export async function addOrUpdateAddressApi(data: any) {
  return requestClient.post<any>('afterSale/addOrEditAddress', data);
}

/** 四级地址 */
export async function getAreaListApi(data: any) {
  return requestClient.get<any>('afterSale/getProvinceCityList', {
    params: data,
  });
}

/** 删除关联的店铺 */
export async function deleteBind1688ShopApi(data: any) {
  return requestClient.post<any>('merchant/delShopById', data);
}

/** 获取单个详情 */
export async function get1688ShopDetailApi(data: any) {
  return requestClient.get<any>('business/getDYGoodsInfo', {
    params: data,
  });
}

/** 售后列表 */
export async function getAfterSaleListApi(data: any) {
  return requestClient.get<any>('order/getAfterSaleOrderList', {
    params: data,
  });
}

/** 申请退款 */
export async function applyRefundApi(data: any) {
  return requestClient.post<any>('order/createRefund', data);
}
/** 取消申请退款 */
export async function cancelRefundApi(data: any) {
  return requestClient.post<any>('order/cancelRefund', data);
}

/** 订单物流轨迹 */
export async function getOrderLogisticsApi(data: any) {
  return requestClient.post<any>('order/getLogisticsTraceInfoList', data);
}

/** 上传关联文件 */
export async function uploadBindFileApi(data: any) {
  return requestClient.post<any>('business/uploadOtherPlatfromGoods', data, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}
